package com.htg.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;


public class DialogWarn {

    private Context cxt;



    public DialogWarn(Context cxt) {
        this.cxt = cxt;
    }

    public void show(String content) {
        AlertDialog.Builder builder = new AlertDialog.Builder(cxt);
        AlertDialog alertDialog = builder.create();



        View view = LayoutInflater.from(cxt).inflate(R.layout.dialog_warn, null);

        TextView tvContent = view.findViewById(R.id.tv_dialog_warnning_content);
        tvContent.setText(content);
        TextView tvOk = view.findViewById(R.id.bt_dialog_warnning_ok);
        tvOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                alertDialog.dismiss();
            }
        });


        alertDialog.setView(view);
        alertDialog.show();



        Window window = alertDialog.getWindow();

        int width = cxt.getResources().getDimensionPixelSize(R.dimen.dp_336);
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.width = width;
        window.setAttributes(layoutParams);
        window.setBackgroundDrawableResource(R.drawable.shape_white_rounded);

    }





}
